#include <iostream>
using namespace std;
class Complex{
public:
    Complex(int real,int image)
    :_real(real)
    ,_image(image)
    {

    }
   friend Complex operator+(const Complex & rhs,const Complex & rhs2);
    void display(void){
        cout<<_real<<"+"<<_image<<"i"<<endl;
    }
private:
    int _real;
    int _image;
};
    //友元函数根本不是成员函数，而是一个普通的类外函数，只是需要它去访问类内的private，友元的存在就是为了去打破类的封装性
   Complex operator+(const Complex & rhs,const Complex & rhs2){
            Complex temp(rhs._real+rhs2._real,rhs._image+rhs2._image);
            return temp;
        }

void test(){
    Complex co1(1,2),co2(2,3);
    Complex co3=co1+co2;
    co3.display();
}
int main(int argc, char * argv[]){
    test();
    return 0;
}

